import Vue from 'vue'
import axios from 'axios';
import VueAxios from 'vue-axios';
import Qs from 'qs';
import VueCookie from "vue-cookie";

Vue.use(VueAxios, axios);

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    config.headers['Accept'] = 'application/json';
    const token = VueCookie.get('token');
    if(token){
        config.headers['Authorization'] = 'Bearer ' + token;
    }
    return config;
}, function (error) {
    return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么

    return response.data;
}, function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
});

// 定义基础路由
let base = '/api';

// 大驼峰命名请求方法名称
//登录
export const Captcha = params => { return axios.get(`${base}/captcha`, params).then(res => res)};
export const UserLogin = params => { return axios.post(`${base}/login`, Qs.stringify(params)).then(res => res)};
//主页
export const Main = params => { return axios.get(`${base}/main`, params).then(res => res)};
//管理人员
export const ManagerList = params => { return axios.get(`${base}/manager`, params).then(res => res)};//列表
export const ManagerUpdate = params => { return axios.post(`${base}/manager/update`, Qs.stringify(params)).then(res => res)};//更新
export const ManagerDestroy = params => { return axios.post(`${base}/manager/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const ManagerLock = params => { return axios.post(`${base}/manager/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const ManagerActive = params => { return axios.post(`${base}/manager/active`, Qs.stringify(params)).then(res => res)};//激活
//广告管理
export const AdsenseList = params => { return axios.get(`${base}/adsense`, params).then(res => res)};//列表
export const AdsenseUpdate = params => { return axios.post(`${base}/adsense/update`, Qs.stringify(params)).then(res => res)};//更新
export const AdsenseDestroy = params => { return axios.post(`${base}/adsense/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const AdsenseLock = params => { return axios.post(`${base}/adsense/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const AdsenseActive = params => { return axios.post(`${base}/adsense/active`, Qs.stringify(params)).then(res => res)};//激活
//系统设置
export const ConfigList = params => { return axios.get(`${base}/config`, params).then(res => res)};//配置
export const ConfigUpdate = params => { return axios.post(`${base}/config/update`, Qs.stringify(params)).then(res => res)};//更新
//SEO
export const SeoList = params => { return axios.get(`${base}/seo`, params).then(res => res)};//列表
export const SeoUpdate = params => { return axios.post(`${base}/seo/update`, Qs.stringify(params)).then(res => res)};//更新
export const SeoDestroy = params => { return axios.post(`${base}/seo/destroy`, Qs.stringify(params)).then(res => res)};//删除
//网站导航
export const ChannelList = params => { return axios.get(`${base}/channel`, params).then(res => res)};//列表
export const ChannelUpdate = params => { return axios.post(`${base}/channel/update`, Qs.stringify(params)).then(res => res)};//更新
export const ChannelDestroy = params => { return axios.post(`${base}/channel/destroy`, Qs.stringify(params)).then(res => res)};//删除
//合作商管理
export const LinkList = params => { return axios.get(`${base}/link`, params).then(res => res)};//列表
export const LinkUpdate = params => { return axios.post(`${base}/link/update`, Qs.stringify(params)).then(res => res)};//更新
export const LinkDestroy = params => { return axios.post(`${base}/link/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const LinkLock = params => { return axios.post(`${base}/link/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const LinkActive = params => { return axios.post(`${base}/link/active`, Qs.stringify(params)).then(res => res)};//激活
//新闻管理
export const ArticleList = params => { return axios.get(`${base}/article`, params).then(res => res)};//列表
export const ArticleCate = params => { return axios.get(`${base}/article/cate`, params).then(res => res)};//分类
export const ArticleInfo = params => { return axios.get(`${base}/article/info`, params).then(res => res)};//详情
export const ArticleUpdate = params => { return axios.post(`${base}/article/update`, Qs.stringify(params)).then(res => res)};//更新
export const ArticleDestroy = params => { return axios.post(`${base}/article/destroy`, Qs.stringify(params)).then(res => res)};//删除
//富润荣誉
export const HonorList = params => { return axios.get(`${base}/honor`, params).then(res => res)};//列表
export const HonorUpdate = params => { return axios.post(`${base}/honor/update`, Qs.stringify(params)).then(res => res)};//更新
export const HonorDestroy = params => { return axios.post(`${base}/honor/destroy`, Qs.stringify(params)).then(res => res)};//删除
//分享管理
export const ShareList = params => { return axios.get(`${base}/share`, params).then(res => res)};//列表
export const ShareCate = params => { return axios.get(`${base}/share/cate`, params).then(res => res)};//分类
export const ShareInfo = params => { return axios.get(`${base}/share/info`, params).then(res => res)};//详情
export const ShareUpdate = params => { return axios.post(`${base}/share/update`, Qs.stringify(params)).then(res => res)};//更新
export const ShareDestroy = params => { return axios.post(`${base}/share/destroy`, Qs.stringify(params)).then(res => res)};//删除
//案例管理
export const CaseList = params => { return axios.get(`${base}/case`, params).then(res => res)};//列表
export const CaseCate = params => { return axios.get(`${base}/case/cate`, params).then(res => res)};//分类
export const CaseInfo = params => { return axios.get(`${base}/case/info`, params).then(res => res)};//详情
export const CaseUpdate = params => { return axios.post(`${base}/case/update`, Qs.stringify(params)).then(res => res)};//更新
export const CaseDestroy = params => { return axios.post(`${base}/case/destroy`, Qs.stringify(params)).then(res => res)};//删除
//合作伙伴
export const PartnerList = params => { return axios.get(`${base}/partner`, params).then(res => res)};//列表
export const PartnerUpdate = params => { return axios.post(`${base}/partner/update`, Qs.stringify(params)).then(res => res)};//更新
export const PartnerDestroy = params => { return axios.post(`${base}/partner/destroy`, Qs.stringify(params)).then(res => res)};//删除
//生态伙伴
export const EcologyList = params => { return axios.get(`${base}/ecology`, params).then(res => res)};//列表
export const EcologyCate = params => { return axios.get(`${base}/ecology/cate`, params).then(res => res)};//分类
export const EcologyUpdate = params => { return axios.post(`${base}/ecology/update`, Qs.stringify(params)).then(res => res)};//更新
export const EcologyDestroy = params => { return axios.post(`${base}/ecology/destroy`, Qs.stringify(params)).then(res => res)};//删除
//胜途ERP
export const ErpList = params => { return axios.get(`${base}/erp`, params).then(res => res)};//列表
export const ErpCate = params => { return axios.get(`${base}/erp/cate`, params).then(res => res)};//分类
export const ErpUpdate = params => { return axios.post(`${base}/erp/update`, Qs.stringify(params)).then(res => res)};//更新
export const ErpDestroy = params => { return axios.post(`${base}/erp/destroy`, Qs.stringify(params)).then(res => res)};//删除
//成功案例
export const DeputyList = params => { return axios.get(`${base}/deputy`, params).then(res => res)};//列表
export const DeputyCate = params => { return axios.get(`${base}/deputy/cate`, params).then(res => res)};//分类
export const DeputyUpdate = params => { return axios.post(`${base}/deputy/update`, Qs.stringify(params)).then(res => res)};//更新
export const DeputyDestroy = params => { return axios.post(`${base}/deputy/destroy`, Qs.stringify(params)).then(res => res)};//删除
//发展历程
export const CourseList = params => { return axios.get(`${base}/course`, params).then(res => res)};//列表
export const CourseUpdate = params => { return axios.post(`${base}/course/update`, Qs.stringify(params)).then(res => res)};//更新
export const CourseDestroy = params => { return axios.post(`${base}/course/destroy`, Qs.stringify(params)).then(res => res)};//删除
//分类
export const CategoryList = params => { return axios.get(`${base}/category`, params).then(res => res)};//列表
export const CategoryUpdate = params => { return axios.post(`${base}/category/update`, Qs.stringify(params)).then(res => res)};//更新
export const CategoryDestroy = params => { return axios.post(`${base}/category/destroy`, Qs.stringify(params)).then(res => res)};//删除










































